package com.hxl.demo.controller;

import com.hxl.demo.entity.Leave;
import com.hxl.demo.entity.TrainingRecord;
import com.hxl.demo.entity.User;
import com.hxl.demo.mapper.LeaveMapper;
import com.hxl.demo.mapper.TrainingContentsMapper;
import com.hxl.demo.mapper.TrainingRecordMapper;
import com.hxl.demo.mapper.UserMapper;
import com.hxl.demo.service.Impl.LeaveServiceImpl;
import com.hxl.demo.service.Impl.TrainingRecodeServiceImpl;
import com.hxl.demo.tools.Common;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;

/**
 * 数据更新
 */
@RestController
@RequestMapping("/admin")
public class LeaveController {
    @Resource
    private LeaveServiceImpl leaveServiceImpl;

    @Resource
    Leave leave;

    @RequestMapping("/leaveList")
    public Object leaveList(
            @RequestParam(name = "limit",required = false) Integer limit,
            @RequestParam(name = "page",required = false) Integer page,
            @RequestParam(name = "id",required = false) Integer id,
            @RequestParam(name = "userName",required = false) String userName
                           ) {
        List<Leave> list = leaveServiceImpl.leaveList(page, limit,id, userName);
        Integer total = leaveServiceImpl.leaveNum(id,userName);
        return Common.returnJsonList("操作成功", 200, list, total);

    }
    @RequestMapping("/leaveDel")
    public Object leaveDel(@RequestParam(name = "id",required = false) Integer id) {
        return leaveServiceImpl.leaveDel(id);

    }

}
